package com.example.demo.Springmytbatis.controller;

import com.example.demo.Springmytbatis.model.UserInfo;
import com.example.demo.Springmytbatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/user")
@RestController
public class UserInfoController {
    @Autowired
    private UserService userService;
    @RequestMapping("/getAlluser")
    //结果返回为集合
    public List<UserInfo> getAllUser(){
        return userService.getAllUser();
    }
    @RequestMapping("/getUserInfoById")
    //结果返回为对象
    public UserInfo getUserInfoById(Integer id){
        return userService.getUserInfoById(id);
    }
    @RequestMapping("/login")
   private boolean selectByUserNameandBypassword(String username,String password){
        List<UserInfo> userInfos = userService.selectByUserNameandBypassword(username, password);
        if(userInfos==null){
            return false;
        }else{
            return true;
        }
    }


    @RequestMapping("/login1")
    private List<UserInfo> selectByUserNameandBypassword1(String username,String password){
        List<UserInfo> userInfos = userService.selectByUserNameandBypassword(username, password);
        if(userInfos==null){
            return null;
        }else{
            return userInfos;
        }
    }

}
